package dao.pojo;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * ShelfCommodityInfo entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "shelf_commodity_info", catalog = "onlinemall")
public class ShelfCommodityInfo implements java.io.Serializable {

	// Fields

	private Integer shelfCommodityId;
	private CommodityInfo commodityInfo;
	private Color color;
	private Size size;
	private Integer inventory;
	private Set<ShoppingCart> shoppingCarts = new HashSet<ShoppingCart>(0);
	private Set<OrderCommodityInfo> orderCommodityInfos = new HashSet<OrderCommodityInfo>(
			0);

	// Constructors

	/** default constructor */
	public ShelfCommodityInfo() {
	}

	/** minimal constructor */
	public ShelfCommodityInfo(CommodityInfo commodityInfo, Color color,
			Size size, Integer inventory) {
		this.commodityInfo = commodityInfo;
		this.color = color;
		this.size = size;
		this.inventory = inventory;
	}

	/** full constructor */
	public ShelfCommodityInfo(CommodityInfo commodityInfo, Color color,
			Size size, Integer inventory, Set<ShoppingCart> shoppingCarts,
			Set<OrderCommodityInfo> orderCommodityInfos) {
		this.commodityInfo = commodityInfo;
		this.color = color;
		this.size = size;
		this.inventory = inventory;
		this.shoppingCarts = shoppingCarts;
		this.orderCommodityInfos = orderCommodityInfos;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "shelf_commodity_id", unique = true, nullable = false)
	public Integer getShelfCommodityId() {
		return this.shelfCommodityId;
	}

	public void setShelfCommodityId(Integer shelfCommodityId) {
		this.shelfCommodityId = shelfCommodityId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "commodity_id", nullable = false)
	public CommodityInfo getCommodityInfo() {
		return this.commodityInfo;
	}

	public void setCommodityInfo(CommodityInfo commodityInfo) {
		this.commodityInfo = commodityInfo;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "color_id", nullable = false)
	public Color getColor() {
		return this.color;
	}

	public void setColor(Color color) {
		this.color = color;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "size_id", nullable = false)
	public Size getSize() {
		return this.size;
	}

	public void setSize(Size size) {
		this.size = size;
	}

	@Column(name = "inventory", nullable = false)
	public Integer getInventory() {
		return this.inventory;
	}

	public void setInventory(Integer inventory) {
		this.inventory = inventory;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "shelfCommodityInfo")
	public Set<ShoppingCart> getShoppingCarts() {
		return this.shoppingCarts;
	}

	public void setShoppingCarts(Set<ShoppingCart> shoppingCarts) {
		this.shoppingCarts = shoppingCarts;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "shelfCommodityInfo")
	public Set<OrderCommodityInfo> getOrderCommodityInfos() {
		return this.orderCommodityInfos;
	}

	public void setOrderCommodityInfos(
			Set<OrderCommodityInfo> orderCommodityInfos) {
		this.orderCommodityInfos = orderCommodityInfos;
	}

}